<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LoginFormValidator
 *
 * @author flocki
 */
namespace Taxx\UserBundle\FormValidators;

use Taxx\KernelBundle\Model\FormValidator\FormValidator;
use Doctrine\ORM\EntityManager;

class LoginFormValidator 
{
    private $em;
    private $request_params;
    
    public function __construct(EntityManager $em, array $request_params)
    {
        $this->em = $em;
        $this->request_params = $request_params;
    }
    
    public function validate()
    {
        $error = false;
        $err_msg = array();
        
        if(FormValidator::isEmpty($this->request_params['username']))
        {
            $error = true;
            array_push($err_msg, "LoginForm -> username -> empty");
        }
        
        if(FormValidator::isEmpty($this->request_params['password']))
        {
            $error = true;
            array_push($err_msg, "LoginForm -> password -> empty");
        }
        
        return array("error"=>$error, "error_msg"=>$err_msg);
    }
}

?>
